Instruction#

class Instruction(op, qubits=[], clbits=[])[source]#

This class combines Operation objects with their operands (ie. qubits and classical bits). The data attribut of the QuantumCircuit class consists of a list of Instructions.

Instructions can be added to QuantumCircuits using the append <qrisp.QuantumCircuit.append> method without any qubit/ classical bit arguments.

Parameters:
opOperation

The Operation object.

qubitslist[Qubit], optional

The list of Qubits on which op should take place. The default is [].

clbitslist[Clbit], optional

The list of Clbits on which op should take place. The default is [].

Examples

We create two Instruction objects, merge them and append the result to a QuantumCircuit.

>>> from qrisp import Instruction, QuantumCircuit, CXGate, XGate
>>> qc = QuantumCircuit(2)
>>> ins_0 = Instruction(XGate(), [qc.qubits[0]])
>>> ins_1 = Instruction(CXGate(), qc.qubits)
>>> merged_ins = ins_0.merge(ins_1)
>>> qc.append(merged_ins)
>>> qc.measure(qc.qubits[1])
>>> qc.run()
{'1': 10000}
>>> print(qc.transpile())
      ┌───┐
qb_0: ┤ X ├──■─────
      └───┘┌─┴─┐┌─┐
qb_1: ─────┤ X ├┤M├
           └───┘└╥┘
cb_0: ═══════════╩═

Methods#

Instruction.copy()

Returns a copy of the Instruction.

Instruction.merge(other)

Merges two instructions into one.